<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<%--
    This file is an entry point for JavaServer Faces application.
--%>
<f:view>
    <html>
        <head>
            <link rel="stylesheet" type="text/css" href="/NamibiaMedicalControl/style.css" title="Variant Stream" media="screen,projection" >
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title><h:outputText value="Visita paziente"/></title>
        </head>
        <body>

            <div id="wrapper">
                <div id="logo">
                    <h1>Namibia medical control</h1>
                    <p><h:outputText value="#{msg.sottotitolo}"/></p>
                </div>
                <hr>
                <!-- end #logo -->
                <div id="header">
                    <div id="menu">
                        <ul>
                            <li><a href="/NamibiaMedicalControl/faces/home.jsp" class="first" >Home</a></li>           
                        </ul>
                    </div>
                    <!-- end #menu -->
                    <div id="search">
                        <div id="search-text">
                            <h:panelGroup rendered="#{loginBean.subview != null}">
                                <jsp:include page="${loginBean.subview}" />
                            </h:panelGroup>
                        </div>
                    </div>
                    <!-- end #search -->
                </div>
                <!-- end #header -->
                <!-- end #header-wrapper -->
                <div id="page">
                    <div id="page-bgtop">
                        <div id="content">
                            <div class="post">
                                <h2 class="title"><h:outputText value="Visita paziente"/></h2>
                                <div class="entry">
                                    <a4j:form id="visita">
                                        I campi con * sono obbligatori
                                        <table border="0" width="700px" cellspacing="10">
                                            <tbody>
                                                <tr>
                                                    <td>*Paziente:</td>
                                                    <td>
                                                        <h:inputText id="input_person" value="#{visitaPazientiBean.input}"/>
                                                        <rich:suggestionbox  for="input_person"
                                                                             suggestionAction="#{pazientiACBean.autocompleteListaPazienti}"
                                                                             fetchValue="#{result.id} #{result.nome} #{result.cognome}"
                                                                             var="result"
                                                                             height="200"
                                                                             width="300" >
                                                            <h:column>
                                                                <h:outputText value="#{result.id}"/>
                                                            </h:column>
                                                            <h:column>
                                                                <h:outputText value="#{result.nome}" />
                                                            </h:column>
                                                            <h:column>
                                                                <h:outputText value="#{result.cognome}"/>
                                                            </h:column>
                                                            <h:column>
                                                                <h:outputText value="#{result.dataNascita}"/>
                                                            </h:column>
                                                        </rich:suggestionbox>
                                                        <h:outputText id="personError" styleClass="error" value="inserire un paziente valido" rendered="#{visitaPazientiBean.renderPazienteError}"/>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>Categoria:</td>
                                                    <td>Visita spontanea</td>
                                                </tr>
                                                <tr>
                                                    <td>Medico curante:</td>
                                                    <td><h:outputText value="#{loginBean.nome} #{loginBean.cognome}"/></td>
                                                </tr>
                                                <tr>
                                                    <td>*Tipologia visita:</td>
                                                    <td>
                                                        <rich:comboBox value="#{visitaPazientiBean.tipologia}"
                                                                       suggestionValues="#{visitaPazientiBean.richiamo}" 
                                                                       directInputSuggestions="true" 
                                                                       defaultLabel="Enter some value"
                                                                       enableManualInput="false"
                                                                       >
                                                            <a4j:support event="onlistclose" action="#{visitaPazientiBean.setData()}" reRender="data"/>
                                                        </rich:comboBox>
                                                        <br>
                                                        <h:outputText styleClass="error" value="selezionare una tipologia" rendered="#{visitaPazientiBean.renderTipologiaError}"/>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>*Descrizione:</td>
                                                    <td> 
                                                        <h:inputTextarea id="descrizione" rows="3" cols="50" value="#{visitaPazientiBean.descrizione}"/> <br>
                                                        <h:outputText styleClass="error" value="descrizione troppo lunga" rendered="#{visitaPazientiBean.renderDescrizioneError_lunga}"/>
                                                        <h:outputText styleClass="error" value="inserire una descrizione" rendered="#{visitaPazientiBean.renderDescrizioneError_corta}"/>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>*Prossima visita:</td>
                                                    <td>
                                                        <rich:calendar id="data"
                                                                       value="#{visitaPazientiBean.data}"
                                                                       datePattern="dd/MM/yyyy HH:mm"
                                                                       enableManualInput="false"
                                                                       cellWidth="24px"
                                                                       cellHeight="22px"
                                                                       style="width:200px"
                                                                       />
                                                        <h:outputText styleClass="error" value="inserire una data valida" rendered="#{visitaPazientiBean.renderCalendarError}"/>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                        <a4j:commandButton type="submit" value="Inserisci dati visita" action="#{visitaPazientiBean.action()}" reRender="visita"/>
                                        <h:outputText value="  Visita registrata con successo" rendered="#{visitaPazientiBean.renderSuccess}"/>
                                        <h:outputText value="  Visita non registrata, provi a ricontrollare i campi inseriti" rendered="#{visitaPazientiBean.renderUnsuccess}"/>
                                    </a4j:form>
                                </div>
                            </div>                           
                        </div>
                        <!-- end #content -->
                        <div id="sidebar">
                            <ul>
                                <li>
                                    <jsp:include page="../subviews/language_chooser.jsp"/>
                                </li>
                                <li>
                                    <jsp:include page="../subviews/side_reserved_menu.jsp"/>
                                </li>
                            </ul>
                        </div>
                        <!-- end #sidebar -->
                        <div style="clear: both;">&nbsp;</div>
                    </div>
                </div>
                <!-- end #page -->
                <div id="footer-bgcontent">
                    <div id="footer">
                        <p>Copyright &copy; 2011 <a href="#">Mamesoft</a>
                            Progetto Programmazione per il web A.A.2011/2012</p>
                    </div>
                </div>
                <!-- end #footer -->
            </div>
        </body>
    </html>
</f:view>